package org.argus.management.data.controller;

import io.swagger.annotations.Api;
import org.argus.common.web.core.data.model.BuildCacheReq;
import org.argus.common.web.core.data.model.BuildCacheResp;
import org.argus.common.core.domain.R;
import org.argus.management.data.service.DataCacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author 刘文/Cliff Liu
 * @Date 2024/7/29
 */
@Api(tags = "数据缓存处理")
@RestController
@RequestMapping("/data/v1/cache")
public class DataCacheController {

    @Autowired
    private DataCacheService dataCacheService;

    @PutMapping("/build")
    public R<BuildCacheResp> buildCache(@RequestBody BuildCacheReq req) {
        Map<String, String> cache = dataCacheService.buildCache(req);
        BuildCacheResp data = new BuildCacheResp();
        data.setKeyValueMap(cache);
        return R.ok(data);
    }
}
